
using UnityEngine;

public class PlayerState_Move : PlayerState
{
    [SerializeField] float walkSpeed = 4f;
    [SerializeField] float runSpeed = 8f;
    private float currentSpeed => input.IsInputRun ? runSpeed : walkSpeed;
    private float weight =>  0;
    public override void LogicalUpdate()
    {
        if(!input.IsInputMove)
        {
            manager.SwitchState(typeof(PlayerState_Idle));
        }
        if(input.IsInputJump)
        {
            manager.SwitchState(typeof(PlayerState_Jump));
        }
        if(!motor.isOnSlope && !motor.isOnGround)
        {
            manager.SwitchState(typeof(PlayerState_Fall));
        }
    }
    public override void PhysicalUpdate()
    {
        motor.SetMoveVelocity(input.MoveValue * (currentSpeed - weight ));
        motor.UseGravity();
    }
    public override void Exit()
    {
        motor.playerGravity.y = 0;
    }
}
